<!DOCTYPE html>
<html lang="zh-cn">

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>错位 丨 Misplace - home</title>

	<!-- Bootstrap CSS -->
	<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<link href="/static/css/newnavbar.css" rel="stylesheet">
	<link type="text/css" href="/static/css/harmony.css"rel="stylesheet">
    <link rel="shortcut icon" href="https://raw.githubusercontent.com/StuGRua/2020_project/main/favicon.ico" type="image/x-icon">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.3/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

	<!--<script type="text/javascript" src="/static/js/nmb_main.js"></script>-->
	{% if no_confirmation == '1'%}
	<script>alert('未通过邮件确认!');</script>
	{% endif %}

</head>
<body style="margin-top:0px">
	<div class="container-fluid">
		<nav class="navbar navbar-default navbar-fixed-top" role="navigation">

			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target="#example-navbar-collapse">
					<span class="sr-only">切换导航</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="/home">错位 丨 Misplace</a>
			</div>
			<div class="collapse navbar-collapse" id="example-navbar-collapse">
				<ul class="nav navbar-nav">

					<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
							{{section}}
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li><a href="/home">时间线</a></li>
							<li><a href="/section/综合">综合</a></li>
							<li><a href="/section/校内">校内</a></li>
							<li><a href="/section/形势与政策">形势与政策</a></li>
							<li><a href="/section/问询">问询</a></li>
							<li><a href="/section/深夜">深夜</a></li>
							<li><a href="/section/其他">其他</a></li>
							<li><a href="/section/反馈">反馈</a></li>
						</ul>
					</li>
					<li class="nav-item dropdown">
						<a class="nav-link" href="#" class="dropdown-toggle" data-toggle="dropdown">
							饼干：{{result.kookies}}
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="/newkookie">获取新饼干</a>
							</li>
						</ul>
					</li>
					<li class="nav-item">
						<a class="nav-link" href="#" class="dropdown-toggle" data-toggle="modal" data-target="#myModal"
							style="padding-top:5px;padding-bottom:0;"><img src="\static/avatars/{{result.avatar}}.jpg"
								height="45px" width="auto">
							<b class="caret"></b>
						</a>

					</li>
					<li class="nav-item">
						<a class="nav-link" id="notiCenter" href="#" data-toggle="modal" data-target="#myModal4">{{result.email}}<b class="caret"></b></a>
					</li>
					<li class="nav-item">
						<a class="nav-link" id="makeNew" href="#" data-toggle="modal" data-target="#myModal3" onclick="checkKookie()">NEW<b class="caret"></b>
						</a>
					</li>
					<li class="nav-item dropdown">
						<a class="nav-link" href="#" class="dropdown-toggle" data-toggle="dropdown">
							注销
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="/logout">确定注销</a>
							</li>
						</ul>
					</li>
				</ul>
			</div>
        </nav>
	</div>


	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						更改头像
					</h4>
				</div>
				<div class="modal-body">
					{% for i in range(0,17)%}
					<a href="/changeavatar/{{i}}"><img src="\static/avatars/{{i}}.jpg" height="100px" width="auto"></a>
					{% endfor %}
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
					<button type="button" class="btn btn-primary">
						提交更改
					</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel">
						通知
					</h4>
				</div>
				<div class="modal-body">

				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel2">
						获取新饼干
					</h4>
				</div>
				<div class="modal-body">
					<a href="/newkookie">
						<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
							点击获取新饼干
						</button>
					</a>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭
					</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>

	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						&times;
					</button>
					<h4 class="modal-title" id="myModalLabel3">
						MAKE NEW
					</h4>
				</div>
				<div class="modal-body">
					<form action="/new" method="post" enctype="multipart/form-data">
						{{newpostform.csrf_token }}
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">{{newpostform.title.label}} {{newpostform.title}}</div>
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">{{newpostform.content.label}} {{newpostform.content(id="post_content")}}</div>
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">{{newpostform.section.label}} {{newpostform.section}}<br></div>
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">{{newpostform.no_show.label}} {{newpostform.no_show}}<br></div>
						<div class="form-group col-sm-6">
							<input type="file" name="pic" class="form-control btn-info">
						</div>
						{{newpostform.submit}}
					</form>

				</div>

				<div class="modal-footer">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <button type="button"  class="btn btn-default" onclick="encoderOn()">打开编码器</button>
                        <button type="button"  class="btn btn-default" onclick="encoderOff()">关闭编码器</button>
                        <button type="button" class="btn btn-default" onclick="copyToText()"><strong>覆盖</strong>编码后的文本到输入框</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭	</button>
                    </div>
                    <hr>
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id="encoderFrame">

                    </div>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" style="margin-top:60px;">

		<div class="well well-lg">
			<h5>公告</h5>
			<h5>更新内容：对和谐编码的模块进行了迁移（变为全前端，避免多次请求）<br>对非核心功能进行了精简<br>变天了，好冷</h5>
			<br>
		</div>
	</div>
	<br>
	{% for posts in topped_posts %}
		<hr>

		<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
			<a href="/viewpost/{{posts.id}}">
				<div class="panel panel-default">
					<div class="panel-heading" style="background-color:#DCDCDC">

						<h3 class="panel-title">

							<p><strong>【置顶】ID:{{posts.id}} [板块：{{posts.section}}] {{posts.title}}</strong></p>


							<p> <img src="/static/avatars/{{posts.avatar}}.jpg" width="30px"
									height="auto">{{posts.poster}}</p>
						</h3>
						<span class="badge">{{posts.replies}}回复</span><span class="badge">最后更新{{posts.update_time}}</span>
					</div>
					<div class="panel-body">

						<p>{%if posts.withpic %}
							<img src="/{{posts.pic_route}}" height="100px" width="auto">
							{% endif %}{{posts.content[0:100]}}</p>
					</div>
				</div>

			</a>

		</div>


		{% endfor %}
	{% for posts in allposts %}
	<hr>

	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
		<a href="/viewpost/{{posts.id}}" style="text-decoration:none">
			<div class="panel panel-default">
				<div class="panel-heading">

					<h3 class="panel-title">
						<p><strong>ID:{{posts.id}} [板块：{{posts.section}}] {{posts.title}}</strong>
						</p>
							<p><img src="/static/avatars/{{posts.avatar}}.jpg" width="30px" height="auto">{{posts.poster}}</p>
					</h3>
					<span class="badge">{{posts.replies}}回复</span><span class="badge">最后更新{{posts.update_time}}</span>
				</div>
				<div class="panel-body">

					<p>{%if posts.withpic %}
						<img src="/{{posts.pic_route}}" height="100px" width="auto">
						{% endif %}<br>{% if posts.content[97] %}{{posts.content[0:97]}}...{% endif %}{% if not posts.content[97] %}{{posts.content}}{% endif %}</p>
				</div>
			</div>


		</a>
	</div>


	{% endfor %}

</body>
<script type="text/javascript" src="/static/js/md5.js"></script>
<script type="text/javascript" src="/static/js/harmoncer.js"></script>
	<script>
		function checkKookie(){
			if({{nokookie}}==1){
			alert('未获得有效饼干,将不能有效发帖.请点击导航栏左侧获取饼干或咨询管理员.');
			$("#makeNew").removeAttr("data-target");
			}
		}</script>
		<script>
    var encoder_section=
        "<script>"+
        "var dl = document.getElementById(\"decode-btn\");\n" +
        "var el = document.getElementById(\"encode-btn\");\n" +
        "var ENC = function() {\n" +
        "    document.getElementById(\"encoded-area\").value=encode(document.getElementById(\"decoded-area\").value);\n" +
        "document.getElementById(\"decoded-area\").value=\"\";"+
        "}\n" +
        "var DEC = function() {\n" +
        "    document.getElementById(\"decoded-area\").value=decode(document.getElementById(\"encoded-area\").value);\n" +
        "    document.getElementById(\"encoded-area\").value=\"\";"+
        "}\n" +
        "dl.onclick=DEC;\n" +
        "el.onclick=ENC;"+
        "<"+"/script>\n"+
        "\t<script>function copyToText(){\n" +
        "\t\tvar a = document.getElementById('encoded-area').value;\n" +
        "\t\talert(a);\n" +
        "\t\tdocument.getElementById(\"post_content\").value=a;\n" +
        "\t}\n" +
        "\t"+"<"+"/script>"+
        "                    <div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-4\">\n" +
        "                        <label for=\"decoded-area\">解码</label>\n" +
        "                        <textarea class=\"form-control\" id=\"decoded-area\" placeholder=\"Decoded Text Here\"></textarea>\n" +
        "                    </div>\n" +
        "\n" +
        "                    <div class=\"btn-group-vertical col-xs-12 col-sm-12 col-md-12 col-lg-4\">\n" +
        "                        <button class=\"btn btn-default\" id='encode-btn'>Encode &gt;&gt;</button>\n" +
        "                        <button class=\"btn btn-default\" id='decode-btn'>&lt;&lt; Decode</button>\n" +
        "                    </div>\n" +
        "\n" +
        "                    <div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-4\">\n" +
        "                        <label for=\"encoded-area\">编码</label>\n" +
        "                        <textarea class=\"form-control\" id=\"encoded-area\" placeholder=\"Encoded Text Here\"></textarea>\n" +
        "                    </div>"

            function encoderOn(id){
            $("#encoderFrame").append(encoder_section);
            }

	        function encoderOff(){
            $("#encoderFrame").empty();
		}
	</script>

    <script>
	function pic_inserted(){
		document.getElementById("reply1").value+="[图片]";
	}
	</script>
</html>
